package com.apes.enquiry.enquiry.service;

import com.alibaba.fastjson.JSONObject;
import com.apes.enquiry.enquiry.model.QuoteResult;
import com.apes.enquiry.enquiry.repository.QuoteResultRepository;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("quoteResultService")
public class QuoteResultService {
    @Autowired
    private QuoteResultRepository quoteResultRepository;

    public double accordPriceNo(SimpleRequest simpleRequest) {
        JSONObject getJO = simpleRequest.getJO();
        List<QuoteResult> quoteResults = quoteResultRepository.accordPriceNo(getJO.getString("priceNo"), getJO.getString("quoteId"));
        if (!quoteResults.isEmpty()) return quoteResults.get(0).getNotTaxUnitPrice();
        return 0.0;
    }

}
